<!--  -->
<template>
  <div class="create-food">
    <div class="food-name demo-input-suffix">
      <label for="foodName">菜谱名:</label>
      <el-input
        placeholder="请输入菜谱名"
        v-model="foodName"
        class="name-value"
        id="foodName"
        clearable
      >
      </el-input>
    </div>
    <div class="cover">
      <label class="cover-text">菜谱封面：</label>
      <el-upload
        action="#"
        :limit="limitFile"
        list-type="picture-card"
        :auto-upload="false"
      >
        <i slot="default" class="el-icon-plus"></i>
        <div slot="file" slot-scope="{ file }">
          <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
          <span class="el-upload-list__item-actions">
            <span
              class="el-upload-list__item-preview"
              @click="handlePictureCardPreview(file)"
            >
              <i class="el-icon-zoom-in"></i>
            </span>
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleDownload(file)"
            >
              <i class="el-icon-download"></i>
            </span>
            <span
              v-if="!disabled"
              class="el-upload-list__item-delete"
              @click="handleRemove(file)"
            >
              <i class="el-icon-delete"></i>
            </span>
          </span>
        </div>
      </el-upload>
    </div>
    <div class="metarials">食材</div>
    <div class="steps">步骤</div>
    <div class="category">所属分类</div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      foodName: "",
      limitFile: 1,
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {
    foodName: function(newVal) {
      this.foodName = newVal;
    }
  },
  //方法集合
  methods: {
    handleRemove(file) {
      console.log(file);
      
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    }
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style scoped>
/**@import url(); 引入公共css类**/
.create-food {
  width: 80%;
  margin: 20px auto;
}
.food-name {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.food-name label {
  width: 4em;
}
.food-name .name-value {
  width: 200px !important;
}
/*封面*/
.cover {
  display: flex;
  align-items: center;
  margin-top: 10px;
}
</style>
